import numpy as np
from matplotlib import pyplot as plt

from input import input_data

def unit_vector_normalization(data: np.ndarray):
    '''单位矢量归一化

    :param data: 待归一化的y值数组，np.ndarray
    :return: 归一化后的y值数组，np.ndarray
    '''
    normalized_data = data / np.linalg.norm(data)
    return normalized_data

if __name__ == "__main__":
    data,_ = input_data()
    size = data.shape[1]
    # size = 100
    x = np.linspace(1, size, size)
    # data = np.random.rand(100) # 返回一个或一组服从“0~1”均匀分布的随机样本值。
    #plt.plot(x,data[0],'r')
    data_normalized = unit_vector_normalization(data)
    plt.plot(x,data_normalized[0],label='data_normalized')
    print(data_normalized[0])
    plt.show()